using System;
using System.Data;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Web.Security;
namespace Main.handlers
{
    /// <summary>
    /// Summary description for $codebehindclassname$
    /// </summary>
    //[WebService(Namespace = "http://tempuri.org/")]
    //[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    public class comment : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            if (context.User.Identity.IsAuthenticated && context.Request.HttpMethod == "POST")
            {
                try 
                {
                    DataAccess.CreateComment((Guid)Membership.GetUser().ProviderUserKey, Convert.ToInt32(context.Request.QueryString["id"]), context.Request["commenttext"], context.Request["commenttitle"]);
                    context.Response.Redirect("/polls/show.aspx?id=" + context.Request.QueryString["id"]);
                }
                catch (Exception)
                {
                    context.Response.Redirect("/polls/show.aspx?id=" + context.Request.QueryString["id"]);
                }
            }
            else
            {
                context.Response.Redirect("/default.aspx");
            }
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}
